package com.itheima.treeSet;

import java.util.Iterator;
import java.util.TreeSet;

/**
 * - 用TreeSet集合存储多个学生信息(姓名,语文成绩,数学成绩,英语成绩),并遍历该集合
 * - 要求: 按照总分从高到低出现
 */
public class Test01 {

    public static void main(String[] args) {
        //创建集合=
        TreeSet<Student> set = new TreeSet<>();
        //创建学生对象
        Student s1 = new Student("鹿晗", 80, 80, 90);
        Student s2 = new Student("关晓彤", 60, 70, 100);
        Student s3 = new Student("吴亦凡", 80, 90, 70);
        Student s4 = new Student("黄子韬", 100, 50, 60);
        Student s5 = new Student("蔡徐坤", 80, 70, 60);


        //添加到集合中
        set.add(s1);
        set.add(s2);
        set.add(s3);
        set.add(s4);
        set.add(s5);

        //遍历
        Iterator<Student> iterator = set.iterator();
        while(iterator.hasNext()){
            Student next = iterator.next();
            System.out.println(next);
        }

        for (Student student : set) {
            System.out.println(student);
        }

    }
}
